-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add metalsmith build #279
Add metalsmith build #279
Conversation
razor-x
commented
Jul 23, 2024
- Add TypeScript project structure
- Add metalsmith
- Add blueprint and types
- Add code-sample
- Add blueprint plugin
- Add codeSampleDefinitions
- Add pages from endpoints
- Only format src
- Add metalsmith layouts plugin
- Add empty layouts
- Add .nvmrc
- Generate files for sdk and api
- Move metalsmith items to dependencies
- Setup layouts
docs/api/acs/systems.md
Outdated
@@ -0,0 +1,3 @@ | |||
# /acs/systems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that this should be /acs/systems/list
@kainpets can you see why this is off in blueprint?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, but I forgot to trigger the automatic release of blueprint when I pushed the fix for this. I've manually released yesterday and this should be fixed with version 0.2.1
docs/sdk/README.md
Outdated
@@ -0,0 +1,2 @@ | |||
# SDK Reference |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file and the other REAMDE can serve as landing pages for each SDK. The content can either live here or we can just generate an index partial to include in the readme via a gitbook include.
} | ||
const file = files[k] as Partial<TemplateContext> | ||
file.layout = 'api-reference.hbs' | ||
file.endpoint = endpoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mastafit We can add something like this instead if we want build a more complicated template context
file.endpoint = endpoint | |
setFileContext(file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@razor-x Sure, just give me some requirements for this one, what exactly such function should do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends on what context we need for the template. So if we write the handlebars template and only need endpoint
, then we are done. But we may need to extend the context, add to it, or transform it, if endpoint
is not enough or hard to use in the template.
Ideally, blueprint would already have what we need so element
should be a good context for the template, but at this stage we are still learning what we need in context.
If this gets too complex, we can move logic into handlebars helpers or back into the blueprint.
For example, one thing we want to do is update URLs to be relative in GitBook, e.g., if a description contains a Markdown link to to https://docs.seam.co/latest/core-concepts/overview
we really want this to link to ../core-concepts/overview
or whatever the correct internal GitBook linking should be.
Another example is we want to generate links to other resources, e.g., The
acs_system is...
should might get transformed to The [
acs_system](../acs_system)
is...`.
We can implement those two things later, I'm just using them as an example. But either it would be handled inside setFileContext
or in the template via a helper like {{ element.description | linkResources | relativeLinks }}
.
This PR does not include registering handlebars helpers, but it should be simple to add that under src/lib
.
src/lib/blueprint.ts
Outdated
// }) | ||
const typesModule = { | ||
...types, | ||
codeSampleDefinitions: (metadata as any).codeSampleDefinitions, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're passing the path to metadata.codeSampleDefinitions
in src/metalsmith.ts
:
.use(
metadata({
codeSampleDefinitions: './data/code-sample-definitions',
}),
)
I suppose we need to read all the definitions from './data/code-sample-definitions'
and pass them instead of the path itself because TypesModuleSchema
expects codeSampleDefinitions: z.array(CodeSampleDefinitionSchema).default([])
according to the ongoing blueprint PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, TypesModuleSchema has all definitions, and then creates and passes only the code samples specific to each endpoint.